package addressbook2;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;

import javax.swing.*;

import java.util.*;



public class NewFrame {
	
	public static JLabel fName = new JLabel("First Name");
	public static JTextField fNameEntry = new JTextField(10);
	public static JLabel lName = new JLabel("Last Name");
	public static JTextField lNameEntry = new JTextField(10);
	public static JLabel group = new JLabel("Group");
	public static JTextField groupEntry = new JTextField(10);
	public static JLabel homeAdd = new JLabel("Home Address");
	public static JTextField homeAddEntry = new JTextField(10);
	public static JLabel compAdd = new JLabel("Company Address");
	public static JTextField compAddEntry = new JTextField(10);
	public static JLabel personalMobile = new JLabel("Personal Mobile");
	public static JTextField personalMobileEntry = new JTextField(10);
	public static JLabel personalLand = new JLabel("Personal Land");
	public static JTextField personalLandEntry = new JTextField(10);
	public static JLabel profMobile = new JLabel("Professional Mobile");
	public static JTextField profMobileEntry = new JTextField(10);
	public static JLabel profLand = new JLabel("Professional Land");
	public static JTextField profLandEntry = new JTextField(10);
	public static JLabel homePage = new JLabel("Home Page Link");
	public static JTextField homePageEntry = new JTextField(10);
	public static JLabel emailId = new JLabel("Email id");
	public static JTextField emailIdEntry = new JTextField(10);
	public static JLabel photo = new JLabel("Photo");
	public static JTextField photoEntry = new JTextField(10);
	public static JLabel date = new JLabel("Date");
	public static JTextField dateEntry = new JTextField(10);	
	public static JButton submitButton = new JButton("Submit");
	/*final BufferedImage image = ImageIO.read(NewFrame.class.getClassLoader().getResource("img/user.png"));
	 protected void paintComponent(Graphics g) {
	        super.paintComponent(g);
	        int centerPoint = (getHeight() - image.getHeight())/2;
	        g.drawImage(image, 0, centerPoint, this);
	    }
	}
	//look for ImageIcon*/
	
	//ADD
	public static void createFrame1(){
		JFrame frame = new JFrame("Add Contact");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		//photoEntry.setMargin(new Insets(0, image.getWidth(), 0, 0));
		//photoEntry.setPreferredSize(new Dimension(textField.getWidth(), image.getHeight() + 10));

		calcPanel.add(fName);
		calcPanel.add(fNameEntry);
		calcPanel.add(lName);
		calcPanel.add(lNameEntry);
		calcPanel.add(group);
		calcPanel.add(groupEntry);
		calcPanel.add(homeAdd);
		calcPanel.add(homeAddEntry);
		calcPanel.add(compAdd);
		calcPanel.add(compAddEntry);
		calcPanel.add(personalMobile);
		calcPanel.add(personalMobileEntry);
		calcPanel.add(personalLand);
		calcPanel.add(personalLandEntry);
		calcPanel.add(profMobile);
		calcPanel.add(profMobileEntry);
		calcPanel.add(profLand);
		calcPanel.add(profLandEntry);
		calcPanel.add(homePage);
		calcPanel.add(homePageEntry);
		calcPanel.add(emailId);
		calcPanel.add(emailIdEntry);
		calcPanel.add(photo);
		calcPanel.add(photoEntry);
		calcPanel.add(date);
		calcPanel.add(dateEntry);
		calcPanel.add(submitButton);
		

		frame.add(calcPanel);
		frame.setVisible(true);

	}

	// DELETE
	public static void createFrame2(){
		JFrame frame = new JFrame("Delete Contact");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		
		calcPanel.add(fName);
		calcPanel.add(fNameEntry);
		calcPanel.add(lName);
		calcPanel.add(lNameEntry);
		calcPanel.add(submitButton);
		
		frame.add(calcPanel);
		frame.setVisible(true);	
		
    }
	
	//EDIT
	public static void createFrame3(){
		JFrame frame = new JFrame("Edit Contact");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		
		calcPanel.add(fName);
		calcPanel.add(fNameEntry);
		calcPanel.add(lName);
		calcPanel.add(lNameEntry);
		calcPanel.add(submitButton);
		
		frame.add(calcPanel);
		frame.setVisible(true);		
	}
	
public static void createFrame_3(Contact contact){
		
		JFrame frame = new JFrame("Edit Details");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(200, 300);
		frame.setLocationRelativeTo(null);	
		String[] fields = contact.split(",");
		calcPanel.add(fName);
		calcPanel.add(fNameEntry);
		fNameEntry.setText(contact.getName());
		calcPanel.add(lName);
		calcPanel.add(lNameEntry);
		lNameEntry.setText(fields[1]);
		calcPanel.add(submitButton);
		
		
//		JScrollPane scrollPane = new JScrollPane();
//		JList list = new JList(data.toArray());
//		scrollPane.setViewportView(list);
		
		frame.add(calcPanel);
		//frame.add(list);
//		frame.add(scrollPane);
		frame.setVisible(true);		
	}
	
	//SORT NAME
	public static void createFrame4(){
		JFrame frame = new JFrame("Sort by Names");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		
		frame.add(calcPanel);
		frame.setVisible(true);		
	}
	
	//SORT GROUP
	public static void createFrame5(){
		JFrame frame = new JFrame("Sort by Group");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		
		calcPanel.add(group);
		calcPanel.add(groupEntry);
		calcPanel.add(submitButton);
		
		frame.add(calcPanel);
		frame.setVisible(true);		
	}
	

	public static void createFrame_5(ArrayList<String> data){
		
		JFrame frame = new JFrame("Sort by Group");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(200, 300);
		frame.setLocationRelativeTo(null);		
		
		JScrollPane scrollPane = new JScrollPane();
		JList list = new JList(data.toArray());
		scrollPane.setViewportView(list);
		
		frame.add(calcPanel);
		//frame.add(list);
		frame.add(scrollPane);
		frame.setVisible(true);		
	}
	
	

	//SORT DATE
	public static void createFrame6(){
		JFrame frame = new JFrame("Sort by Date");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		
		frame.add(calcPanel);
		frame.setVisible(true);		
	}
	
	//DISPLAY 
	public static void createFrame7(){
		JFrame frame = new JFrame("Display Contact");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(600, 200);
		frame.setLocationRelativeTo(null);
		
		calcPanel.add(fName);
		calcPanel.add(fNameEntry);
		calcPanel.add(lName);
		calcPanel.add(lNameEntry);
		calcPanel.add(submitButton);
		
		frame.add(calcPanel);
		frame.setVisible(true);	
	}

	public static void createFrame_7(ArrayList<String> data){
		
		JFrame frame = new JFrame("Display Details");
		JPanel calcPanel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(200, 300);
		frame.setLocationRelativeTo(null);		
		
		JScrollPane scrollPane = new JScrollPane();
		JList list = new JList(data.toArray());
		scrollPane.setViewportView(list);
		
		frame.add(calcPanel);
		//frame.add(list);
		frame.add(scrollPane);
		frame.setVisible(true);		
	}
	
}
